Consider the linear program: $$ \left.\begin{array}{rrcl} \max & -2x+y \\ \text {s.t.:} & & & \\ & -x + y \leq 1 \text{ (Constraint 1)}\\ & x+y \geq 0 \text{ (Constraint 2)} \\ & x, y \geq 0 \text{ (Non-negativity)} \\ \end{array}\right\} $$


In [8]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

In [10]:
x = [0, 4, 4, 3, 0]
y = [0, 0, 4, 4, 1]

plt.fill(x,y)
plt.show()



In [41]:
fig = plt.figure()
ax = plt.axes()
 
x = np.linspace(0, 2, 500)
ax.plot(x, x+1, linestyle='--', label='y = x+1');
ax.plot(x, -x, linestyle='--')
ax.plot(x, 0*x, linestyle='--')

ax.plot(x, 2*x+1, linestyle='-')

plt.fill_between(x, x+1, 0*x, color='grey', alpha='0.5')


Out[41]:
<matplotlib.collections.PolyCollection at 0xc349d68>

In [ ]: